package com.wf.course.web.controller.member;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import com.utils.page.PageBean;
import com.wf.course.model.member.MemberDevice;
import com.wf.course.service.IMemberDeviceService;
import com.wf.course.web.Interceptor.LogInfo;

@Controller
@RequestMapping("MemberDevice")
public class MemberDeviceController {
	@Autowired
	private IMemberDeviceService mdserice;
	
	/**
	 * 用户端设备:列表
	 * @param pageNo
	 * @param pageSize
	 * @param userName
	 * @param telephone
	 * @param model
	 * @return
	 */
	@LogInfo("用户端设备:列表")
	@RequestMapping("memberDeviceList")
	public String memberDeviceList(
			@RequestParam(value="pageNo",required=false) Integer pageNo,
			@RequestParam(value="pageSize",required=false) Integer pageSize,
			@RequestParam(value="userName",required=false) String userName,
			@RequestParam(value="telephone",required=false) String telephone,
			Model model){
		Map<String, Object> map = new HashMap<>();
		map.put("userName", userName);
		map.put("telephone", telephone);
		
		PageBean<MemberDevice> pageBean = new PageBean<MemberDevice>(pageNo,pageSize,null,map);
		mdserice.getMemberDeviceList(pageBean);
		pageBean.setUrl("MemberDevice/memberDeviceList");
		
		model.addAttribute("page",pageBean);
		return "member/memberDeviceList";
	}
	
	/**
	 * 删除一条用户端设备
	 * @param id
	 * @return
	 */
	@LogInfo("删除一条用户端设备")
	@RequestMapping(value = "removememberDevice/{id}")
	public String removememberDevice(@PathVariable("id") Integer id) {
		
		mdserice.delMemberDevice(id);
		
		return "redirect:/MemberDevice/memberDeviceList";
	}
}
